True if this instance’s whole collision box, standing at (x, y), would be clear of the room’s own solid ground - the tile grid and any obstacles the room has. The room-as-wall twin of pos_free: use it to ask "may I step here?" for anything that moves.
tile_free(x, y) -> bool| Name | Type |
|---|---|
x | real |
y | real |
bool
True if this instance could stand at (x, y) without any part of it being inside the room's own solid ground. It is pos_free for the case where the thing in your way is the room itself - the painted tiles - and not an object.
x and y are a place in the room, counted from the room's top-left corner, the same way this instance's own x and y are counted. Nothing moves. The game only asks "if I stood there, would I be stuck?"
This is the difference from tile_solid. tile_solid(x, y) looks at one tile, the one under the single point you give it. An instance is not a point. It has a collision box (see Overlap and collision), and a 16 by 16 box covers four tiles at once, because tiles are only 8 by 8. If the box is not lined up with the grid it can cover nine. Ask about one point and the other corners can walk straight into a wall.
tile_free uses the same box as pos_free: the one set by mask_w, mask_h, mask_x and mask_y, or by the sprite if you set none of them. It moves that box so the instance's x and y would be (x, y), then looks up every tile the box touches. Each lookup goes straight to the tile, so the answer takes a handful of lookups, never a search through all your instances. It does not get slower as the level grows.
TILE_SOLID and TILE_LOW_COVER stop a body. Only TILE_PASS is free. This is the body question, the same one tile_solid answers. There is no projectile version, because a projectile is a single point. Use tile_blocks_projectile for those.tile_free, from any side, so a thing that does not know about One-way platforms falls straight through one. Ask tile_one_way to make a thing stand on it.slope_feet to ask for the whole box instead. Squares with no shape are full, as before.tile_solid follows.move_slide walks on. An answer of true means move_slide would not be stopped there either.tile_free calls it free everywhere: neither the tiles nor the room's obstacles are asked about it, even where the point stands in solid ground. pos_free is not the same here: it can find a solid instance that has the point strictly inside it (see Overlap and collision).A solid instance is not part of this. A wall made from obj_wall objects is still a job for pos_free. Tiles are the room's own ground, and tile_free reads only that.
if (tile_free(x + hsp, y)) {
x += hsp;
}
if (tile_free(x, y + vsp)) {
y += vsp;
}Moves the walker one direction at a time. Each step happens only if the walker's whole box would be clear of solid ground at the new place. Splitting it into two steps means that when one direction is blocked, the walker slides along the wall instead of stopping dead. Swap tile_free(x + hsp, y) for pos_free(x + hsp, y, obj_wall) and you have the same code for walls made of objects.
Tests the BOX, not a point: the same box mask_w/mask_h/mask_x/mask_y (or mask_sprite/sprite) describe, moved so the instance’s own x and y would be (x, y) - exactly what pos_free moves. A 16 by 16 box covers about four 8-pixel tiles (up to nine when it is not lined up with the grid), and every one of them is looked up directly - a handful of lookups, never a search through instances, so it does not get slower as a level grows. It is the same check move_slide makes, so "free" here means move_slide would not be stopped there. The BODY question: TILE_SOLID and TILE_LOW_COVER both block, only TILE_PASS is free - there is no projectile twin, because a projectile is a point (see tile_blocks_projectile). The part of the box outside the room blocks nothing: the edge of a room is not a wall. A room with no collision layer has no grid to block anything, so every place is free. An instance with no box (no sprite and no mask size) is free everywhere: neither the tiles nor the obstacles are asked about it. (pos_free is different: it can find a solid instance with the point strictly inside.)